home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byteibm.arc / WILTON.ARC / CSLS7.ASM < prev   
Encoding:
Assembly Source File  |  1985-07-12  |  5.9 KB  |  231 lines

  1.             title    'extended character set for the HGC Plus'
  2.             name    csls7
  3.             page    55,132
  4.  
  5. ;
  6. ; RAM-Loadable Character Sets for the IBM PC
  7. ; Listing 7
  8. ;
  9. ; Richard Wilton
  10. ; July 1986
  11. ;
  12.  
  13. ; Notes:
  14. ;    This program makes available two different 256-character definition
  15. ;    tables for use on the Hercules Graphics Card Plus.  The first table
  16. ;    consists of the ROM BIOS 8 by 8 "double-dot" characters.  The
  17. ;    second table is the reverse of the first (i.e., black on white rather
  18. ;    than white on black).
  19. ;
  20. ;    For Hercules Graphics Card Plus ONLY.
  21.  
  22.  
  23. cseg    segment para public 'CODE'
  24.  
  25.     assume    cs:cseg,ds:cseg
  26.  
  27.     org    100h            ; initial program counter for .COM file
  28.  
  29. ; set configuration switch on HGC Plus
  30. label0:    mov    dx,3BFh            ; i/o port address
  31.     mov    al,1            ; activate RAM from B000:0000
  32.     out    dx,al            ;  through B000:7FFF
  33.  
  34. ; Copy 1st 256 character definitions into character generator RAM from BIOS ROM
  35.     mov    ax,0F000h
  36.     mov    ds,ax
  37.     mov    si,0FA6Eh        ; DS:SI -> start of 8x8 character
  38.                     ;  definition table in ROM
  39.     mov    ax,0B000h
  40.     mov    es,ax
  41.     mov    di,4000h        ; ES:DI -> start of Hercules font
  42.                     ;  definition storage area
  43.  
  44.     xor    al,al            ; AL := zero byte (used for padding)
  45.     mov    cx,256            ; CX := # of characters in table
  46.  
  47. label1:    push    cx            ; preserve loop counter
  48.  
  49.     mov    cx,8            ; CX := # of bytes in one character
  50.                     ;  definition
  51.     rep    movsb            ; copy to HGC font storage area
  52.  
  53.     mov    cx,8            ; CX := # of bytes of padding
  54.     rep    stosb            ; store zeroes
  55.  
  56.     pop    cx            ; loop across all 256 characters
  57.     loop    label1
  58.  
  59. ; Copy 2nd 256 character definitions into character generator RAM
  60.     mov    ax,0B000h
  61.     mov    ds,ax
  62.     mov    si,4000h        ; DS:SI -> start of 8x8 character
  63.                     ;  definition table in HGC Plus RAM
  64.     mov    cx,256*16        ; CX := size of 256-character table
  65.  
  66. label2:    lodsb                ; copy "reverse" of 1st 256 chars ...
  67.     not    al
  68.     stosb                ; .. into table for 2nd 256 chars
  69.     loop    label2
  70.  
  71. ; Program the CRT controller to display 25 lines of 8 by 14 characters.
  72.     mov    dx,3B4h            ; CRT controller register index port
  73.  
  74.     push    cs
  75.     pop    ds
  76.     mov    si,offset regs00_0D    ; DS:SI -> start of table of register
  77.                     ;  values
  78.  
  79.     mov    cx,0Eh            ; CX := loop counter
  80.     xor    ah,ah            ; AH := 0 (initial CRT controller
  81.                     ;  register number)
  82. label3:    mov    al,ah
  83.     out    dx,al            ; store CRT controller index reg
  84.     
  85.     lodsb                ; AL := data for CRT controller reg
  86.     inc    dx            ; DX := 3B5h (CRT data reg port)
  87.     out    dx,al            ; store data to CRT controller reg
  88.     dec    dx            ; DX := 3B4h
  89.  
  90.     inc    ah            ; AH := next CRT controller index #
  91.     loop    label3
  92.  
  93.     mov    cx,3
  94.     mov    ah,14h            ; index value for xModeReg
  95.  
  96. label4:    mov    al,ah            ; Same loop for extra CRT controller ..
  97.     out    dx,al            ; .. regs used with extended ..
  98.                     ; .. character set
  99.     lodsb
  100.     inc    dx
  101.     out    dx,al
  102.     dec    dx
  103.  
  104.     inc    ah
  105.     loop    label4
  106.  
  107. ; Update BIOS RAM area in segment 40h
  108.     mov    ax,40h
  109.     mov    ds,ax
  110.     mov    word ptr ds:[4Ah],90    ; CRT_COLS := 90
  111.     mov    word ptr ds:[4Ch],1400h    ; CRT_LEN := 90 columns * 25 rows
  112.                     ;  * 2 bytes/char, rounded up to next
  113.                     ;  higher 1K
  114. ; Display a message
  115.     push    cs
  116.     pop    ds
  117.     mov    dx,1859h        ; use BIOS scroll routine ...
  118.     mov    cx,0            ; .. to set attribute bytes in ..
  119.     mov    bh,0            ; .. display buffer to zero
  120.     mov    ax,600h
  121.     int    10h
  122.  
  123.     mov    si,offset csmsg0    ; 1st message
  124.     mov    bl,0            ; BL (high nibble) := 0 (normal attrib)
  125.                     ; BL (low nibble) := 0 (1st 256 chars)
  126.     mov    cx,48            ; length of string
  127.     call    show            ; display string using char set 0
  128.  
  129.  
  130.     mov    si,offset csmsg1    ; 2nd message
  131.     mov    bl,81h            ; BL (hi nibble) := 8 (intense video)
  132.                     ; BL (lo nibble) := 1 (2nd 256 chars)
  133.     mov    cx,49
  134.     call    show            ; display string using char set 1
  135.  
  136. ; Pause, then disable RAM character generator and restore original state
  137.     mov    si,offset KeyMsg
  138.     mov    bl,0
  139.     mov    cx,33
  140.     call    show            ; display "Press a key" message
  141.  
  142.     mov    ah,1
  143.     int    21h            ; wait for a keypress
  144.  
  145.     mov    al,14h            ; write xModeReg ...
  146.     mov    dx,3B4h
  147.     out    dx,al            ; .. to disable extended character set
  148.     mov    al,0
  149.     inc    dx
  150.     out    dx,al
  151.  
  152.     mov    ax,7
  153.     int    10h            ; call BIOS, restore default video mode
  154.  
  155. ; Exit to DOS
  156.     mov    ax,4C00h
  157.     int    21h
  158.  
  159.  
  160.  
  161. ; Subroutine which displays a string using a given attribute
  162.  
  163. show    proc    near            ; Caller:    DS:SI -> string
  164.                     ;        CX = length of string
  165.                     ;        BL = attribute
  166.     jcxz    show2
  167.  
  168. show1:    lodsb                ; AL := next char
  169.     call    emit            ; display this character
  170.     loop    show1
  171.  
  172. show2:    ret
  173.  
  174. show    endp
  175.  
  176.  
  177. ; Subroutine which displays a single character using a given attribute
  178. ; Bits 0-3 of the attribute byte and bits 0-7 of the character form an
  179. ; 12-bit extended character code. Bits 4-7 of the attribute byte determine
  180. ; the actual attribute displayed.
  181.  
  182. emit    proc    near            ; Caller:    AL = character
  183.                     ;        BL = attribute
  184.                     ; Returns:    nothing, but advances
  185.                     ;         the cursor
  186.     push    bx
  187.     push    cx
  188.  
  189.     cmp    al,20h
  190.     jb    emit1            ; jump if control character
  191.  
  192.     push    ax            ; save char on stack
  193.     mov    cx,1            ; CX := # of chars to write
  194.     mov    bh,0            ; BH := video display page 0
  195.     mov    ah,9            ; call BIOS to write attribute and
  196.     int    10h            ;  character at cursor
  197.     pop    ax            ; AL := character
  198.  
  199. emit1:    mov    ah,0Eh            ; call BIOS to rewrite character in
  200.     int    10h            ;  "teletype mode" which advances
  201.                     ;  the cursor
  202.     pop    cx
  203.     pop    bx
  204.     ret
  205.  
  206. emit    endp
  207.  
  208.  
  209. ; table of CRT controller register values
  210.  
  211. regs00_0D    db    6Dh,5Ah,5Ch,0Fh        ; regs 0 - 3 (8 wide)
  212.         db    19h,06h,19h,19h        ; regs 4 - 7 (14 high)
  213.         db    02h,0Dh,0Ch,0Dh        ; regs 8 - 0Bh (scans/char,
  214.                         ;  cursor location)
  215.         db    00h,00h            ; regs 0Ch - 0Dh (always zero)
  216.  
  217. xModeReg    db    07h            ; "48K RamFont", 8 dot wide
  218.                         ;  characters
  219. ScoreReg    db    0Dh            ; underscore reg
  220. StrikeReg    db    06h            ; overstrike reg
  221.  
  222. ; Strings to be displayed
  223.  
  224. csmsg0    db    'These characters are in the first group of 256',0Dh,0Ah
  225. csmsg1    db    'These characters are in the second group of 256',0Dh,0Ah
  226. KeyMsg    db    0Dh,0Ah,'Press any key to continue ...',0Dh,0Ah
  227.  
  228. cseg    ends
  229.  
  230.     end    label0
  231.